﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AliyunOpenSearch4Net.Base;
using Newtonsoft.Json;

namespace AliyunOpenSearch4Net.App
{
    class AppListRequest : RequestBase<AppListResponse>
    {
        public AppListRequest()
            : base(string.Empty)
        {

        }

        public int Page { get; set; }

        public int PageSize { get; set; }

        protected override void RegisterQueryItems(IList<KeyValuePair<string, string>> list)
        {
            list.Add("page", Page.ToString());
            list.Add("page_size", PageSize.ToString());
        }
    }

    /// <summary>
    /// Application item
    /// </summary>
    public class AppItem
    {
        /// <summary>
        /// Gets or sets the identifier.
        /// </summary>
        /// <value>
        /// The identifier.
        /// </value>
        [JsonProperty("id")]
        public int Id { get; set; }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        /// <value>
        /// The name.
        /// </value>
        [JsonProperty("name")]
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets the description.
        /// </summary>
        /// <value>
        /// The description.
        /// </value>
        [JsonProperty("description")]
        public string Description { get; set; }

        /// <summary>
        /// Gets or sets the created time.
        /// </summary>
        /// <value>
        /// The created time.
        /// </value>
        [JsonProperty("created")]
        [JsonConverter(typeof(UnixTicksDateTimeConverter))]
        public DateTime Created { get; set; }
    }

    /// <summary>
    /// Application list response
    /// </summary>
    public class AppListResponse : Response<AppItem[]>
    {
        /// <summary>
        /// Gets or sets the total.
        /// </summary>
        /// <value>
        /// The total.
        /// </value>
        [JsonProperty("total")]
        public int Total { get; set; }
    }
}
